import request from "../utils/request";
import uploadBigFile from "./uploadBigFile"

// 上传文件
export const imageFileUpload = (data) => {
    return request.post("/File/ImageFileUpload", data)
}

// 上传全景图
export const senceImageFileUpload = (data, callBack = () => {}) => {
    return request({
        url: "/File/SenceImageFileUpload",
        method: 'post',
        data,
        onUploadProgress: function (progressEvent) {
            if (progressEvent.lengthComputable) {
                //属性lengthComputable主要表明总共需要完成的工作量和已经完成的工作是否可以被测量
                //如果lengthComputable为false，就获取不到progressEvent.total和progressEvent.loaded
                callBack(Number(progressEvent.loaded / progressEvent.total * 100).toFixed(2))
            }
        }
    })
}

// 转换全景图
export const getOneKrpano = (params) => {
    return request.get("/Symbol/GetOneKrpano", {
        params
    })
}

// 上传模型（gltf)
export const upLoadFile = (data, callBack = () => {}) => {
    return request({
        url: "/Symbol/UpLoadFile",
        method: 'post',
        data,
        onUploadProgress: function (progressEvent) {
            if (progressEvent.lengthComputable) {
                //属性lengthComputable主要表明总共需要完成的工作量和已经完成的工作是否可以被测量
                //如果lengthComputable为false，就获取不到progressEvent.total和progressEvent.loaded
                callBack(Number(progressEvent.loaded / progressEvent.total * 100).toFixed(2))
            }
        }
    })
}

// 上传模型（3dtile,压缩为zip)
export const fileUpload = (data, callBack = () => {}) => {
    return request({
        url: '/File/FileUpload',
        method: 'post',
        data,
        timeout: 10 * 60 * 1000,
        onUploadProgress: function (progressEvent) {
            if (progressEvent.lengthComputable) {
                //属性lengthComputable主要表明总共需要完成的工作量和已经完成的工作是否可以被测量
                //如果lengthComputable为false，就获取不到progressEvent.total和progressEvent.loaded
                callBack(Number(progressEvent.loaded / progressEvent.total * 100).toFixed(2))
            }
        }
    })
}